From 9764ddf8b2575164449363a0b45cf38ad88478d6 Mon Sep 17 00:00:00 2001 From: Adrian Vovk Date: Fri, 27 Feb 2026 15:58:17 -0500 Subject: [PATCH] systemActions: Switch to updated CanShutdown() API There's corresponding changes in gnome-session that report more detail about the availability of the action. This allows gnome-shell to appropriately hide the action whenever it is inhibited, and would lead to a Polkit prompt. Part-of: --- data/dbus-interfaces/org.gnome.SessionManager.xml | 2 +- js/misc/gnomeSession.js | 7 +++++++ js/misc/systemActions.js | 8 ++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/data/dbus-interfaces/org.gnome.SessionManager.xml b/data/dbus-interfaces/org.gnome.SessionManager.xml index c81c90f08..74a3a2e55 100644 --- a/data/dbus-interfaces/org.gnome.SessionManager.xml +++ b/data/dbus-interfaces/org.gnome.SessionManager.xml @@ -6,7 +6,7 @@ - + diff --git a/js/misc/gnomeSession.js b/js/misc/gnomeSession.js index 218250429..45526c74b 100644 --- a/js/misc/gnomeSession.js +++ b/js/misc/gnomeSession.js @@ -62,3 +62,10 @@ export const InhibitFlags = { IDLE: 1 << 3, AUTOMOUNT: 1 << 4, }; + +export const ActionAvailability = { + UNAVAILABLE: 0, + BLOCKED: 1, + CHALLENGE: 2, + AVAILABLE: 3, +}; diff --git a/js/misc/systemActions.js b/js/misc/systemActions.js index 710d42fa5..eb358e37a 100644 --- a/js/misc/systemActions.js +++ b/js/misc/systemActions.js @@ -82,6 +82,7 @@ const SystemActions = GObject.registerClass({ super._init(); this._canHavePowerOff = true; + this._powerOffNeedsAuth = false; this._canHaveSuspend = true; function tokenizeKeywords(keywords) { @@ -345,10 +346,12 @@ const SystemActions = GObject.registerClass({ async _updateHaveShutdown() { try { - const [canShutdown] = await this._session.CanShutdownAsync(); - this._canHavePowerOff = canShutdown; + const [availability] = await this._session.CanShutdownAsync(); + this._canHavePowerOff = availability !== GnomeSession.ActionAvailability.UNAVAILABLE; + this._powerOffNeedsAuth = availability === GnomeSession.ActionAvailability.CHALLENGE; } catch { this._canHavePowerOff = false; + this._powerOffNeedsAuth = false; } this._updatePowerOff(); } @@ -356,6 +359,7 @@ const SystemActions = GObject.registerClass({ _updatePowerOff() { const disabled = (Main.sessionMode.isLocked && !this._screenSaverSettings.get_boolean(RESTART_ENABLED_KEY)) || + (Main.sessionMode.isLocked && this._powerOffNeedsAuth) || (Main.sessionMode.isGreeter && this._loginScreenSettings.get_boolean(DISABLE_RESTART_KEY)); this._actions.get(POWER_OFF_ACTION_ID).available = this._canHavePowerOff && !disabled; -- 2.39.5